a) Field of the Invention
The present invention relates to a nonvolatile memory such as an EEPROM and an electronic device which utilizes the nonvolatile memory.
b) Description of Related Art and Problems Addressed by the Invention
A nonvolatile memory (for example, EEPROM or flash memory) has been conventionally utilize as a memory in which a stored content can be maintained even when a power supply is interrupted and in which a stored content is capable of being rewritten electrically. This nonvolatile memory has a limit in the number of times of rewriting for each rewriting minimum unit (2 bytes, for example). Therefore, development of various memory techniques has been performed to extend the service lifetime of a memory as long as possible while assuring its number of times of rewriting.
One of the memory techniques is that the rewriting number of times for each rewriting minimum unit is preserved as a memory management data in a nonvolatile memory and updating data is rewritten on the basis of this memory management data.
For example, a memory region to be recorded with updating data is determined in advance on the basis of the above-mentioned memory management data and the data is written into an appropriate memory region. In this manner, the rewriting number of times in all memory regions is uniformed to be capable of extending the service lifetime of the memory. Further, rewriting of data is continuously performed in a specified memory region and, when a limited number of times is reached on the basis of the memory management data, the place of the recorded data is changed to be recorded in another memory region. In this manner, the updating of data can be performed more than the limited number of times of rewriting (see, for example, Japanese Patent Laid-Open No. Hei 8-287697, paragraph [0002]).
When a nonvolatile memory is used as a counter which counts the number of times of occurrence of a certain event the latter prior art of the two memory techniques described above is utilized. However, when the memory management data is updated (incremented) each time the event occurs (counted), the memory management data (rewriting number of times) becomes to be equal to the count value itself which is the number of times of occurrence of the event. Therefore, in this case, the court value itself is used as a judging item of the memory management and the memory region for writing data is changed.
More specifically, when the updating number of times of a counter reaches an upper knit number of times of rewriting, count is newly started from “zero” in another memory region. Further, when the total sum value of the counter is to be acquired, the total sum of all memory regions which have been used as a counter is obtained.
However, in the case that a nonvolatile memory is used as a counter, when the above-mentioned memory technique is utilized, a processing which rewrites a blank is repeatedly performed in a memory region of a blank digit (digit where data is zero). Therefore, the memory region reaches its service lifetime even when the memory region is not used as a counter function and thus a memory is not used efficiently.
For example, when a count-up is to be performed to 1,600,000 times by using a nonvolatile memory whose rewriting minimum unit (one block) is one word (2 bytes) and whose rewriting upper limit number of times in each block is 1,000,000 times, the following steps will be performed.
First, in one block of the nonvolatile memory, count-up can be performed up to 65,536 (=216) times. In other words, 1,000,000 times of count-up which is the upper limit number of times of rewriting cannot be performed with only one block. Therefore, in order to count-up to 1,000,000 times which is the upper limit number of times of rewriting, another memory region of 4 bits is required in addition to one block (2 bytes). When a memory region of 2 bytes and 4 bits is provided, count-up can be performed up to 220 times=1,048,576 times.
However, as described above, when the minimum unit for rewriting in an nonvolatile memory is one block (2 bytes), two blocks of memory region are required.
As a result; when count-up to 16,000,000 times is to be performed by using a method in which, when writing to a memory region of 2 blocks (count-up to 1,000,000 times) has been finished, next writing starts from zero in another memory region of 2 blocks, a memory region of 2 blocks×16=32 blocks is required. However, actually, in respective 2 blocks, the data of a counter value is not written and only erase rewriting is performed in 1 byte at the highest position and a higher 1 nibble (1 nibble=4 bits) in the higher third byte position. Therefore, the region of the 1 byte at the highest position and the higher 1 nibble in the higher third byte position is left to be unused as a counter function (see FIG. 10). Accordingly, the memory is not used efficiently and effectively.